package com.kk.mediator.smarthouse;

/**
 * 中介者模式，客户端不通过目标对象本身去掉目标方法，而是通过中介者对象去调用目标方法
 *
 * @author o_o
 * @date 2022-06-17
 */
public class Client {
    public static void main(String[] args) {

        //创建中介者对象
        CurrentMediator mediator = new CurrentMediator();


        AlarmClock alarmClock = new AlarmClock(mediator, "AlarmClock");
        TV tv = new TV(mediator, "TV");

        //注册
        mediator.register(alarmClock.name, alarmClock);
        mediator.register(tv.name, tv);

        alarmClock.sendMessage(1);
        alarmClock.sendMessage(0);
        tv.sendMessage(0);
        tv.sendMessage(1);

    }
}
